<?php
namespace DesignPatterns\Creational\Multiton;

final class Multiton {
    const INSTANCE_1 = '1';
    const INSTANCE_2 = '2';

    private static $instances = [];

    public static function getInstance(string $instanceName): Multiton {
        if ( !isset(self::$instances[$instanceName]) ) self::$instances[$instanceName] = new self();

        return self::$instances[$instanceName];
    }

    private function __construct() {} // 禁止实例化
    private function __clone() {} // 禁止克隆
    private function __wakeup() {} // 禁止反序列化
}
